package com.architecture.core.web.actions;

import com.architecture.core.web.vo.PageDataVO;
import com.architecture.core.web.vo.PermissionQueryVO;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.stereotype.Controller;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: hjg
 * Date: 12-11-20
 * Time: 上午10:24
 * To change this template use File | Settings | File Templates.
 */
@Controller("permissionListAction")
@Results({
        @Result(name = "list", location = "front/user/permission_list.jsp")
})
public class PermissionListAction extends AbstractAction {

//    @Resource
//    private BasePermissionService basePermissionService;

    private PermissionQueryVO permissionQueryVO = new PermissionQueryVO();

    private PageDataVO pageDataVO = new PageDataVO();

    private List<Map<String, Object>> permissionList = new ArrayList<Map<String, Object>>();

    @Override
    @Action(value = "permission_list")
    public String execute() {
        try {
            return super.execute();
        } catch (Exception ex) {

        }
        return null;
    }

    @Action(value = "query_user_list")
    public String queryUserList() {

//        try {
//            if (null == super.getSessionMap().get(super.CURRENT_ID)) {
//                throw new ErrException(ErrCode.BLANK_ID);
//            }
//
//            String queryHql = HqlUtils.assemblyPermissionHql(this.getPermissionQueryVO(), Permission.class);
//            Integer firstIndex = this.getPageDataVO().getCurrentPage() - 1 * ConfigUtil.getInt(ConfigUtil.W_DEFAULT_PAGE_SIZE);
//            this.setPermissionList(this.basePermissionService.queryListOfMapByPermission(queryHql, firstIndex, super.getSessionMap().get(super.CURRENT_ID).toString()));
//
//            return super.LIST;
//        } catch (ErrException err) {
//            err.printStackTrace();
//            super.addActionError(err.getMessage());
//        }

        return super.ERROR;

    }

    public PermissionQueryVO getPermissionQueryVO() {
        return permissionQueryVO;
    }

    public void setPermissionQueryVO(PermissionQueryVO permissionQueryVO) {
        this.permissionQueryVO = permissionQueryVO;
    }

    public PageDataVO getPageDataVO() {
        return pageDataVO;
    }

    public void setPageDataVO(PageDataVO pageDataVO) {
        this.pageDataVO = pageDataVO;
    }

    public List<Map<String, Object>> getPermissionList() {
        return permissionList;
    }

    public void setPermissionList(List<Map<String, Object>> permissionList) {
        this.permissionList = permissionList;
    }
}
